using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using Oracle.ManagedDataAccess.Client;
using OracleInternal.Common;

namespace OracleInternal.ServiceObjects
{
	internal class SQLParser
	{
		private const uint SQL_TOKTYP_EXTRACTOR = 268435455u;

		private const uint SQL_TOKATR_EXTRACTOR = 4026531840u;

		private const uint SQL_TOKATR_WILDCARD = 268435456u;

		private const uint SQL_TOKATR_PSEUDOCOL = 536870912u;

		private const uint SQL_TOKATR_NORMALCOL = 0u;

		private const int dotRowIdLen = 6;

		private const int MAX_LITERAL_SIZE = 4100;

		internal const string SQL_COLUMN_ROWID = "ROWID";

		private const ushort UCS2_HASH = 65283;

		private const ushort UCS2_DOLLAR = 65284;

		private const ushort UCS2_UNDERSCORE = 65343;

		private static string s_replaceString = "\r\n";

		private static bool SqlPreLocalBuild(string commandText, bool addRowid, out List<SqlData> sqlTokList, out List<SqlData> tableList, out uint numberOfTables, out bool distinct, out bool wildcard, out bool onlyWildcard, out bool rowIdCol, out bool parseFailed)
		{
			sqlTokList = null;
			tableList = null;
			numberOfTables = 0u;
			wildcard = false;
			onlyWildcard = false;
			distinct = false;
			rowIdCol = false;
			parseFailed = false;
			if (!SqlLocalParse(commandText, out rowIdCol, out wildcard, out onlyWildcard, out distinct, out numberOfTables, out tableList, out sqlTokList))
			{
				parseFailed = true;
				return false;
			}
			if ((numberOfTables > 1 && addRowid) | distinct)
			{
				return false;
			}
			return true;
		}

		private static bool SqlLocalParse(string commandText, out bool bFoundRowidInSql, out bool wildcard, out bool onlyWildcard, out bool distinct, out uint numberOfTables, out List<SqlData> tableList, out List<SqlData> sqlTokList)
		{
			numberOfTables = 0u;
			sqlTokList = null;
			tableList = new List<SqlData>();
			bFoundRowidInSql = (wildcard = (onlyWildcard = (distinct = false)));
			if (!SqlParse(commandText, out sqlTokList))
			{
				return false;
			}
			SqlReadSQLTokenList(sqlTokList, ref tableList, out numberOfTables, out wildcard, out onlyWildcard, out distinct, out bFoundRowidInSql);
			return true;
		}

		private static bool SqlParse(string sqlStmt, out List<SqlData> sqlDataList)
		{
			sqlDataList = new List<SqlData>();
			SqlMicTokTyp sqlMicTokTyp = SqlMicTokTyp.I_UNKNOWN;
			SqlMicTokTyp sqlMicTokTyp2 = SqlMicTokTyp.I_UNKNOWN;
			SqlMacTokTyp sqlMacTokTyp = SqlMacTokTyp.A_UNKNOWN;
			SqlMacTokTyp sqlMacTokTyp2 = SqlMacTokTyp.A_UNKNOWN;
			SqlState sqlState = SqlState.S_BEGSQL;
			bool flag = false;
			bool flag2 = false;
			StringBuilder stringBuilder = new StringBuilder();
			int num = 0;
			int num2 = 0;
			bool flag3 = false;
			bool flag4 = false;
			SqlMacTokTyp sqlMacTokTyp3 = SqlMacTokTyp.A_UNKNOWN;
			string text = sqlStmt;
			int pos = 0;
			int length = text.Length;
			while (sqlState != SqlState.S_UNKNOWN)
			{
				sqlMicTokTyp = SqlGetNextToken(text, length, out var tokenString, ref pos);
				switch (sqlMicTokTyp)
				{
				case SqlMicTokTyp.I_FINITO:
					if (sqlState == SqlState.S_INTABLE)
					{
						if (stringBuilder.Length != 0)
						{
							sqlDataList.Add(new SqlData(stringBuilder.ToString(), (uint)sqlMacTokTyp2, 0u));
							stringBuilder.Length = 0;
						}
					}
					else
					{
						sqlState = SqlState.S_UNKNOWN;
					}
					break;
				case SqlMicTokTyp.I_COMMA:
					switch (sqlState)
					{
					case SqlState.S_INCOLUMN:
						sqlState = SqlState.S_NEWCOLUMN;
						if (stringBuilder.Length != 0)
						{
							uint id = (uint)(flag3 ? (sqlMacTokTyp2 | (SqlMacTokTyp)536870912) : sqlMacTokTyp2);
							sqlDataList.Add(new SqlData(stringBuilder.ToString(), id, 0u));
							stringBuilder.Length = 0;
						}
						flag3 = false;
						sqlMacTokTyp = SqlMacTokTyp.A_COMMA;
						sqlDataList.Add(new SqlData(tokenString, (uint)sqlMacTokTyp, 0u));
						break;
					case SqlState.S_INTABLE:
						sqlState = SqlState.S_NEWTABLE;
						if (stringBuilder.Length != 0)
						{
							sqlDataList.Add(new SqlData(stringBuilder.ToString(), (uint)sqlMacTokTyp2, 0u));
							stringBuilder.Length = 0;
						}
						sqlMacTokTyp = SqlMacTokTyp.A_COMMA;
						sqlDataList.Add(new SqlData(tokenString, (uint)sqlMacTokTyp, 0u));
						break;
					default:
						sqlState = SqlState.S_UNKNOWN;
						break;
					}
					break;
				case SqlMicTokTyp.I_DOT:
				case SqlMicTokTyp.I_AT:
					switch (sqlState)
					{
					case SqlState.S_INCOLUMN:
						sqlMacTokTyp = SqlMacTokTyp.A_COLUMN;
						stringBuilder.Append(tokenString);
						break;
					case SqlState.S_INTABLE:
						sqlMacTokTyp = SqlMacTokTyp.A_TABLE;
						stringBuilder.Append(tokenString);
						break;
					default:
						sqlState = SqlState.S_UNKNOWN;
						break;
					}
					break;
				case SqlMicTokTyp.I_ASTERISK:
					switch (sqlState)
					{
					case SqlState.S_SELECT:
					case SqlState.S_NEWCOLUMN:
						sqlState = SqlState.S_INCOLUMN;
						sqlMacTokTyp = SqlMacTokTyp.A_COLUMN;
						sqlDataList.Add(new SqlData(tokenString, (uint)(sqlMacTokTyp | (SqlMacTokTyp)268435456), 0u));
						break;
					case SqlState.S_INCOLUMN:
						if (sqlMicTokTyp2 == SqlMicTokTyp.I_DOT)
						{
							sqlMacTokTyp = SqlMacTokTyp.A_COLUMN;
							stringBuilder.Append(tokenString);
							sqlDataList.Add(new SqlData(stringBuilder.ToString(), (uint)(sqlMacTokTyp | (SqlMacTokTyp)268435456), 0u));
							stringBuilder.Length = 0;
						}
						else
						{
							sqlMacTokTyp = SqlMacTokTyp.A_COLUMN;
							sqlMicTokTyp = SqlMicTokTyp.I_OPER;
							flag4 = true;
							flag3 = true;
							stringBuilder.Append(tokenString);
						}
						break;
					default:
						sqlState = SqlState.S_UNKNOWN;
						break;
					}
					break;
				case SqlMicTokTyp.I_BPAREN:
					if (sqlState == SqlState.S_SELECT || sqlState == SqlState.S_NEWCOLUMN || sqlState == SqlState.S_INCOLUMN)
					{
						sqlMacTokTyp = SqlMacTokTyp.A_COLUMN;
						sqlState = SqlState.S_INCOLUMN;
						num++;
						flag3 = true;
						flag4 = false;
						stringBuilder.Append(tokenString);
						while (num != 0)
						{
							tokenString = string.Empty;
							while (pos < length && char.IsWhiteSpace(text[pos]))
							{
								pos++;
								stringBuilder.Append(" ");
							}
							if (pos >= length)
							{
								sqlState = SqlState.S_UNKNOWN;
								break;
							}
							SqlMicTokTyp sqlMicTokTyp4 = SqlGetNextToken(text, length, out tokenString, ref pos);
							if (sqlMicTokTyp4 == SqlMicTokTyp.I_FINITO || sqlMicTokTyp4 == SqlMicTokTyp.I_UNKNOWN || sqlMicTokTyp4 == SqlMicTokTyp.I_ERROR)
							{
								sqlState = SqlState.S_UNKNOWN;
								break;
							}
							stringBuilder.Append(tokenString);
							switch (sqlMicTokTyp4)
							{
							case SqlMicTokTyp.I_EPAREN:
								num--;
								break;
							case SqlMicTokTyp.I_BPAREN:
								num++;
								break;
							}
						}
						sqlMicTokTyp = SqlMicTokTyp.I_EPAREN;
						tokenString = string.Empty;
					}
					else
					{
						sqlState = SqlState.S_UNKNOWN;
					}
					break;
				case SqlMicTokTyp.I_OPER:
					if (sqlState == SqlState.S_INCOLUMN)
					{
						flag4 = true;
						sqlMacTokTyp = SqlMacTokTyp.A_COLUMN;
						flag3 = true;
						stringBuilder.Append(tokenString);
					}
					else
					{
						sqlState = SqlState.S_UNKNOWN;
					}
					break;
				case SqlMicTokTyp.I_NUMLIT:
				case SqlMicTokTyp.I_NCHARLIT:
				case SqlMicTokTyp.I_CHARLIT:
					if (sqlState == SqlState.S_SELECT || sqlState == SqlState.S_NEWCOLUMN)
					{
						sqlState = SqlState.S_INCOLUMN;
					}
					if (sqlState == SqlState.S_INCOLUMN)
					{
						if (stringBuilder.Length != 0)
						{
							sqlMacTokTyp = SqlMacTokTyp.A_COLUMN;
							uint id = (uint)(flag3 ? (sqlMacTokTyp | (SqlMacTokTyp)536870912) : sqlMacTokTyp);
							if (sqlMicTokTyp2 != SqlMicTokTyp.I_OPER && sqlMicTokTyp2 != SqlMicTokTyp.I_DOT)
							{
								sqlDataList.Add(new SqlData(stringBuilder.ToString(), id, 0u));
								stringBuilder.Length = 0;
							}
						}
						flag4 = false;
						sqlMacTokTyp = SqlMacTokTyp.A_COLUMN;
						flag3 = true;
						stringBuilder.Append(tokenString);
					}
					else
					{
						sqlState = SqlState.S_UNKNOWN;
					}
					break;
				case SqlMicTokTyp.I_COMMENT:
				case SqlMicTokTyp.I_HINT:
					flag2 = true;
					if (stringBuilder.Length != 0)
					{
						sqlMacTokTyp = sqlMacTokTyp2;
						sqlDataList.Add(new SqlData(stringBuilder.ToString(), (uint)sqlMacTokTyp, 0u));
						stringBuilder.Length = 0;
					}
					sqlDataList.Add(new SqlData(tokenString, 13u, 0u));
					break;
				case SqlMicTokTyp.I_VARCHAR:
					switch (SqlGetMacroTokenType(tokenString))
					{
					case SqlMacTokTyp.A_SELECT:
						if (sqlState == SqlState.S_BEGSQL)
						{
							sqlState = SqlState.S_SELECT;
							sqlMacTokTyp = SqlMacTokTyp.A_SELECT;
							sqlDataList.Add(new SqlData(tokenString, (uint)sqlMacTokTyp, 0u));
						}
						else
						{
							sqlState = SqlState.S_UNKNOWN;
						}
						break;
					case SqlMacTokTyp.A_FROM:
						if (sqlState == SqlState.S_INCOLUMN)
						{
							sqlState = SqlState.S_FROM;
							if (stringBuilder.Length != 0)
							{
								uint id = (uint)(flag3 ? (sqlMacTokTyp2 | (SqlMacTokTyp)536870912) : sqlMacTokTyp2);
								sqlDataList.Add(new SqlData(stringBuilder.ToString(), id, 0u));
								stringBuilder.Length = 0;
								flag3 = false;
							}
							sqlMacTokTyp = SqlMacTokTyp.A_FROM;
							sqlDataList.Add(new SqlData(tokenString, (uint)sqlMacTokTyp, 0u));
						}
						else
						{
							sqlState = SqlState.S_UNKNOWN;
						}
						break;
					case SqlMacTokTyp.A_AFTERFROM:
						if (sqlState == SqlState.S_INTABLE)
						{
							sqlState = SqlState.S_ENDSQL;
							if (stringBuilder.Length != 0)
							{
								sqlDataList.Add(new SqlData(stringBuilder.ToString(), (uint)sqlMacTokTyp2, 0u));
								stringBuilder.Length = 0;
							}
							sqlMacTokTyp = SqlMacTokTyp.A_AFTERFROM;
							sqlDataList.Add(new SqlData(tokenString, (uint)sqlMacTokTyp, 0u));
						}
						else
						{
							sqlState = SqlState.S_UNKNOWN;
						}
						break;
					case SqlMacTokTyp.A_AS:
						if (sqlState == SqlState.S_INCOLUMN || sqlState == SqlState.S_INTABLE)
						{
							if (stringBuilder.Length != 0)
							{
								uint id;
								if (flag3 && sqlState == SqlState.S_INCOLUMN)
								{
									id = (uint)(sqlMacTokTyp2 | (SqlMacTokTyp)536870912);
									flag3 = false;
								}
								else
								{
									id = (uint)sqlMacTokTyp2;
								}
								sqlDataList.Add(new SqlData(stringBuilder.ToString(), id, 0u));
								stringBuilder.Length = 0;
								sqlMacTokTyp = SqlMacTokTyp.A_AS;
								sqlDataList.Add(new SqlData(tokenString, (uint)sqlMacTokTyp, 0u));
							}
							else if (flag2)
							{
								flag2 = false;
							}
							else
							{
								sqlState = SqlState.S_UNKNOWN;
							}
						}
						else
						{
							sqlState = SqlState.S_UNKNOWN;
						}
						break;
					case SqlMacTokTyp.A_ALL:
						if (stringBuilder.Length != 0)
						{
							sqlMacTokTyp = sqlMacTokTyp2;
							sqlDataList.Add(new SqlData(stringBuilder.ToString(), (uint)sqlMacTokTyp2, 0u));
							stringBuilder.Length = 0;
						}
						sqlDataList.Add(new SqlData(tokenString, 1u, 0u));
						break;
					case SqlMacTokTyp.A_DISTINCT:
						if (stringBuilder.Length != 0)
						{
							sqlMacTokTyp = sqlMacTokTyp2;
							sqlDataList.Add(new SqlData(stringBuilder.ToString(), (uint)sqlMacTokTyp2, 0u));
							stringBuilder.Length = 0;
						}
						sqlDataList.Add(new SqlData(tokenString, 3u, 0u));
						break;
					case SqlMacTokTyp.A_UNIQUE:
						if (stringBuilder.Length != 0)
						{
							sqlMacTokTyp = sqlMacTokTyp2;
							sqlDataList.Add(new SqlData(stringBuilder.ToString(), (uint)sqlMacTokTyp2, 0u));
							stringBuilder.Length = 0;
						}
						sqlDataList.Add(new SqlData(tokenString, 2u, 0u));
						break;
					case SqlMacTokTyp.A_CASE:
						if (sqlState == SqlState.S_SELECT || sqlState == SqlState.S_NEWCOLUMN || sqlState == SqlState.S_INCOLUMN)
						{
							stringBuilder.Append(tokenString);
							string text2 = text;
							int pos2 = pos;
							int length2 = text2.Length;
							while (pos2 < length2 && char.IsWhiteSpace(text2[pos2]))
							{
								pos2++;
								stringBuilder.Append(" ");
							}
							string tokenString2 = string.Empty;
							SqlMicTokTyp sqlMicTokTyp3 = SqlGetNextToken(text2, length2, out tokenString2, ref pos2);
							if (sqlMicTokTyp3 != SqlMicTokTyp.I_EPAREN && sqlMicTokTyp3 != SqlMicTokTyp.I_CHARLIT && sqlMicTokTyp3 != SqlMicTokTyp.I_BPAREN)
							{
								while (string.Compare(tokenString2, "when", ignoreCase: true) != 0)
								{
									stringBuilder.Append(tokenString2);
									while (pos2 < length2 && char.IsWhiteSpace(text2[pos2]))
									{
										pos2++;
										stringBuilder.Append(" ");
									}
									sqlMicTokTyp3 = SqlGetNextToken(text2, length2, out tokenString2, ref pos2);
									if (sqlMicTokTyp3 == SqlMicTokTyp.I_FINITO || sqlMicTokTyp3 == SqlMicTokTyp.I_UNKNOWN || sqlMicTokTyp3 == SqlMicTokTyp.I_ERROR)
									{
										sqlState = SqlState.S_UNKNOWN;
										break;
									}
								}
							}
							if (string.Compare(tokenString2, "when", ignoreCase: true) == 0 && sqlMicTokTyp3 != SqlMicTokTyp.I_EPAREN && sqlMicTokTyp3 != SqlMicTokTyp.I_CHARLIT && sqlMicTokTyp3 != SqlMicTokTyp.I_BPAREN)
							{
								num2++;
								stringBuilder.Append(tokenString2);
								while (num2 != 0)
								{
									while (pos2 < length2 && char.IsWhiteSpace(text2[pos2]))
									{
										pos2++;
										stringBuilder.Append(" ");
									}
									tokenString2 = string.Empty;
									sqlMicTokTyp3 = SqlGetNextToken(text2, length2, out tokenString2, ref pos2);
									if (sqlMicTokTyp3 == SqlMicTokTyp.I_FINITO || sqlMicTokTyp3 == SqlMicTokTyp.I_UNKNOWN || sqlMicTokTyp3 == SqlMicTokTyp.I_ERROR)
									{
										sqlState = SqlState.S_UNKNOWN;
										break;
									}
									stringBuilder.Append(tokenString2);
									if (string.Compare(tokenString2, "end", ignoreCase: true) == 0)
									{
										num2--;
									}
									else if (string.Compare(tokenString2, "case", ignoreCase: true) == 0)
									{
										num2++;
									}
								}
								sqlDataList.Add(new SqlData(stringBuilder.ToString(), 15u, 0u));
								sqlMacTokTyp = SqlMacTokTyp.A_CASE;
								sqlState = SqlState.S_INCOLUMN;
								flag3 = true;
								flag4 = false;
								stringBuilder.Length = 0;
								tokenString = string.Empty;
								tokenString2 = string.Empty;
								text = text2;
								flag = true;
							}
							else
							{
								stringBuilder.Length = 0;
								flag = false;
							}
							pos = pos2;
						}
						if (flag)
						{
							flag = false;
						}
						break;
					case SqlMacTokTyp.A_PSEUDOCOL:
						flag3 = true;
						goto case SqlMacTokTyp.A_UNKNOWN;
					case SqlMacTokTyp.A_UNKNOWN:
						switch (sqlState)
						{
						case SqlState.S_SELECT:
						case SqlState.S_NEWCOLUMN:
							sqlState = SqlState.S_INCOLUMN;
							sqlMacTokTyp = SqlMacTokTyp.A_COLUMN;
							stringBuilder.Append(tokenString);
							break;
						case SqlState.S_INCOLUMN:
							if (sqlMacTokTyp2 == SqlMacTokTyp.A_AS)
							{
								sqlMacTokTyp = SqlMacTokTyp.A_COLALIAS;
								stringBuilder.Append(tokenString);
							}
							else if (flag4)
							{
								sqlMacTokTyp = SqlMacTokTyp.A_COLUMN;
								flag4 = false;
								stringBuilder.Append(tokenString);
							}
							else if (sqlMacTokTyp2 == SqlMacTokTyp.A_CASE)
							{
								sqlMacTokTyp = SqlMacTokTyp.A_COLUMN;
								sqlDataList.Add(new SqlData(tokenString, 6u, 0u));
								tokenString = string.Empty;
							}
							else if (sqlMicTokTyp2 != SqlMicTokTyp.I_OPER && sqlMicTokTyp2 != SqlMicTokTyp.I_DOT && sqlMicTokTyp2 != SqlMicTokTyp.I_AT)
							{
								if (stringBuilder.Length != 0)
								{
									sqlMacTokTyp = SqlMacTokTyp.A_COLUMN;
									uint id = (uint)(flag3 ? (sqlMacTokTyp | (SqlMacTokTyp)536870912) : sqlMacTokTyp);
									sqlDataList.Add(new SqlData(stringBuilder.ToString(), id, 0u));
									stringBuilder.Length = 0;
									flag3 = false;
								}
								sqlMacTokTyp = SqlMacTokTyp.A_COLALIAS;
								stringBuilder.Append(tokenString);
							}
							else
							{
								sqlState = SqlState.S_INCOLUMN;
								sqlMacTokTyp = sqlMacTokTyp2;
								stringBuilder.Append(tokenString);
							}
							break;
						case SqlState.S_FROM:
						case SqlState.S_NEWTABLE:
							sqlState = SqlState.S_INTABLE;
							sqlMacTokTyp = SqlMacTokTyp.A_TABLE;
							stringBuilder.Append(tokenString);
							break;
						case SqlState.S_INTABLE:
							if (sqlMacTokTyp2 == SqlMacTokTyp.A_AS)
							{
								sqlMacTokTyp = SqlMacTokTyp.A_TABALIAS;
								stringBuilder.Append(tokenString);
							}
							else if (sqlMicTokTyp2 == SqlMicTokTyp.I_VARCHAR || sqlMicTokTyp2 == SqlMicTokTyp.I_COMMENT)
							{
								if (stringBuilder.Length != 0)
								{
									sqlMacTokTyp = SqlMacTokTyp.A_TABLE;
									sqlDataList.Add(new SqlData(stringBuilder.ToString(), (uint)sqlMacTokTyp, 0u));
									stringBuilder.Length = 0;
								}
								if (string.Compare(tokenString, "cross", ignoreCase: true) == 0)
								{
									sqlState = SqlState.S_UNKNOWN;
									break;
								}
								sqlMacTokTyp = SqlMacTokTyp.A_TABALIAS;
								stringBuilder.Append(tokenString);
							}
							else
							{
								sqlState = SqlState.S_INTABLE;
								sqlMacTokTyp = sqlMacTokTyp2;
								stringBuilder.Append(tokenString);
							}
							break;
						}
						break;
					}
					break;
				}
				sqlMicTokTyp2 = sqlMicTokTyp;
				sqlMacTokTyp2 = sqlMacTokTyp;
				tokenString = string.Empty;
				if (sqlState == SqlState.S_ENDSQL || sqlMicTokTyp == SqlMicTokTyp.I_FINITO)
				{
					if (stringBuilder.Length != 0)
					{
						sqlDataList.Add(new SqlData(stringBuilder.ToString(), 13u, 0u));
						stringBuilder.Length = 0;
					}
					if (pos < length)
					{
						sqlDataList.Add(new SqlData(text.Substring(pos), 13u, 0u));
					}
					break;
				}
			}
			if (sqlState == SqlState.S_UNKNOWN)
			{
				return false;
			}
			return true;
		}

		private static void SqlReadSQLTokenList(List<SqlData> tokenList, ref List<SqlData> tableList, out uint numberOfTables, out bool wildCard, out bool onlyWildCard, out bool distinct, out bool bFoundRowidInSql)
		{
			tableList = new List<SqlData>();
			numberOfTables = 0u;
			wildCard = false;
			onlyWildCard = true;
			distinct = false;
			bFoundRowidInSql = false;
			foreach (SqlData token in tokenList)
			{
				if (!bFoundRowidInSql)
				{
					if (string.Compare(token.m_data, "rowid", ignoreCase: true) == 0)
					{
						bFoundRowidInSql = true;
					}
					else
					{
						int num = token.m_data.LastIndexOf(".rowid", StringComparison.InvariantCultureIgnoreCase);
						if (num != -1 && num == token.m_data.Length - 6)
						{
							bFoundRowidInSql = true;
						}
					}
				}
				uint num2 = token.m_id & 0xFFFFFFFu;
				uint num3 = token.m_id & 0xF0000000u;
				switch (num2)
				{
				case 8u:
					tableList.Add(new SqlData(token.m_data, ++numberOfTables, 8u));
					break;
				case 9u:
					tableList.Add(new SqlData(token.m_data, numberOfTables, 9u));
					break;
				case 6u:
					if (num3 == 268435456)
					{
						wildCard = true;
					}
					else
					{
						onlyWildCard = false;
					}
					break;
				case 2u:
				case 3u:
					distinct = true;
					break;
				}
			}
		}

		private static SqlMicTokTyp SqlGetNextToken(string sqlString, int sqlStringLen, out string tokenString, ref int pos)
		{
			SqlMicTokTyp sqlMicTokTyp = SqlMicTokTyp.I_UNKNOWN;
			if (pos >= sqlStringLen)
			{
				tokenString = string.Empty;
				return SqlMicTokTyp.I_FINITO;
			}
			while (char.IsWhiteSpace(sqlString[pos]))
			{
				pos++;
				if (pos >= sqlStringLen)
				{
					tokenString = string.Empty;
					return SqlMicTokTyp.I_FINITO;
				}
			}
			StringBuilder stringBuilder = new StringBuilder();
			switch (sqlString[pos])
			{
			case ',':
				sqlMicTokTyp = SqlMicTokTyp.I_COMMA;
				stringBuilder.Append(sqlString[pos++]);
				break;
			case '.':
				sqlMicTokTyp = SqlMicTokTyp.I_DOT;
				stringBuilder.Append(sqlString[pos++]);
				break;
			case '@':
				sqlMicTokTyp = SqlMicTokTyp.I_AT;
				stringBuilder.Append(sqlString[pos++]);
				break;
			case '(':
				sqlMicTokTyp = SqlMicTokTyp.I_BPAREN;
				stringBuilder.Append(sqlString[pos++]);
				break;
			case ')':
				sqlMicTokTyp = SqlMicTokTyp.I_EPAREN;
				stringBuilder.Append(sqlString[pos++]);
				break;
			case '+':
			case '=':
				sqlMicTokTyp = SqlMicTokTyp.I_OPER;
				stringBuilder.Append(sqlString[pos++]);
				break;
			case '*':
				sqlMicTokTyp = SqlMicTokTyp.I_ASTERISK;
				stringBuilder.Append(sqlString[pos++]);
				break;
			case '|':
				if (pos + 1 < sqlStringLen && sqlString[pos + 1] == '|')
				{
					sqlMicTokTyp = SqlMicTokTyp.I_OPER;
					stringBuilder.Append(sqlString[pos++]);
					stringBuilder.Append(sqlString[pos++]);
				}
				else
				{
					sqlMicTokTyp = SqlMicTokTyp.I_UNKNOWN;
					stringBuilder.Append(sqlString[pos++]);
				}
				break;
			case '!':
				if (pos + 1 < sqlStringLen && sqlString[pos + 1] == '=')
				{
					sqlMicTokTyp = SqlMicTokTyp.I_OPER;
					stringBuilder.Append(sqlString[pos++]);
					stringBuilder.Append(sqlString[pos++]);
				}
				else
				{
					sqlMicTokTyp = SqlMicTokTyp.I_UNKNOWN;
					stringBuilder.Append(sqlString[pos++]);
				}
				break;
			case '<':
			case '>':
				if (pos + 1 < sqlStringLen && sqlString[pos + 1] == '=')
				{
					sqlMicTokTyp = SqlMicTokTyp.I_OPER;
					stringBuilder.Append(sqlString[pos++]);
					stringBuilder.Append(sqlString[pos++]);
				}
				else
				{
					sqlMicTokTyp = SqlMicTokTyp.I_OPER;
					stringBuilder.Append(sqlString[pos++]);
				}
				break;
			case '/':
				if (pos + 1 < sqlStringLen && sqlString[pos + 1] == '*')
				{
					if (pos + 2 < sqlStringLen && sqlString[pos + 2] == '+')
					{
						sqlMicTokTyp = SqlMicTokTyp.I_HINT;
						stringBuilder.Append(sqlString[pos++]);
						stringBuilder.Append(sqlString[pos++]);
						stringBuilder.Append(sqlString[pos++]);
					}
					else
					{
						sqlMicTokTyp = SqlMicTokTyp.I_COMMENT;
						stringBuilder.Append(sqlString[pos++]);
						stringBuilder.Append(sqlString[pos++]);
					}
				}
				else
				{
					sqlMicTokTyp = SqlMicTokTyp.I_OPER;
					stringBuilder.Append(sqlString[pos++]);
				}
				if (sqlMicTokTyp != SqlMicTokTyp.I_HINT && sqlMicTokTyp != SqlMicTokTyp.I_COMMENT)
				{
					break;
				}
				while (true)
				{
					if (pos >= sqlStringLen)
					{
						sqlMicTokTyp = SqlMicTokTyp.I_UNKNOWN;
						break;
					}
					if (pos + 1 < sqlStringLen && sqlString[pos] == '*' && sqlString[pos + 1] == '/')
					{
						stringBuilder.Append(sqlString[pos++]);
						stringBuilder.Append(sqlString[pos++]);
						break;
					}
					stringBuilder.Append(sqlString[pos++]);
				}
				break;
			case '-':
				if (pos + 1 < sqlStringLen && sqlString[pos + 1] == '-')
				{
					if (pos + 2 < sqlStringLen && sqlString[pos + 2] == '+')
					{
						sqlMicTokTyp = SqlMicTokTyp.I_HINT;
						stringBuilder.Append(sqlString[pos++]);
						stringBuilder.Append(sqlString[pos++]);
						stringBuilder.Append(sqlString[pos++]);
					}
					else
					{
						sqlMicTokTyp = SqlMicTokTyp.I_COMMENT;
						stringBuilder.Append(sqlString[pos++]);
						stringBuilder.Append(sqlString[pos++]);
					}
				}
				else
				{
					sqlMicTokTyp = SqlMicTokTyp.I_OPER;
					stringBuilder.Append(sqlString[pos++]);
				}
				if (sqlMicTokTyp != SqlMicTokTyp.I_HINT && sqlMicTokTyp != SqlMicTokTyp.I_COMMENT)
				{
					break;
				}
				while (true)
				{
					if (pos >= sqlStringLen)
					{
						sqlMicTokTyp = SqlMicTokTyp.I_UNKNOWN;
						break;
					}
					if (sqlString[pos] == '\n')
					{
						stringBuilder.Append(sqlString[pos]);
						break;
					}
					stringBuilder.Append(sqlString[pos++]);
				}
				break;
			case '\'':
				sqlMicTokTyp = SqlMicTokTyp.I_CHARLIT;
				stringBuilder.Append(sqlString[pos++]);
				while (true)
				{
					if (pos >= sqlStringLen)
					{
						sqlMicTokTyp = SqlMicTokTyp.I_UNKNOWN;
						break;
					}
					if (sqlString[pos] == '\'')
					{
						if (pos + 1 >= sqlStringLen || sqlString[pos + 1] != '\'')
						{
							stringBuilder.Append(sqlString[pos++]);
							break;
						}
						stringBuilder.Append(sqlString[pos++]);
						stringBuilder.Append(sqlString[pos++]);
					}
					else
					{
						stringBuilder.Append(sqlString[pos++]);
					}
				}
				break;
			case 'N':
				if (pos + 1 < sqlStringLen && sqlString[pos + 1] == '\'')
				{
					sqlMicTokTyp = SqlMicTokTyp.I_NCHARLIT;
					stringBuilder.Append(sqlString[pos++]);
					stringBuilder.Append(sqlString[pos++]);
					while (true)
					{
						if (pos >= sqlStringLen)
						{
							sqlMicTokTyp = SqlMicTokTyp.I_UNKNOWN;
							break;
						}
						if (sqlString[pos] == '\'')
						{
							if (pos + 1 >= sqlStringLen || sqlString[pos + 1] != '\'')
							{
								stringBuilder.Append(sqlString[pos++]);
								break;
							}
							stringBuilder.Append(sqlString[pos++]);
							stringBuilder.Append(sqlString[pos++]);
						}
						else
						{
							stringBuilder.Append(sqlString[pos++]);
						}
					}
				}
				else
				{
					sqlMicTokTyp = SqlMicTokTyp.I_VARCHAR;
					stringBuilder.Append(sqlString[pos++]);
					while (pos < sqlStringLen && (char.IsLetterOrDigit(sqlString[pos]) || sqlString[pos] == '_' || sqlString[pos] == '\uff3f' || sqlString[pos] == '$' || sqlString[pos] == '＄' || sqlString[pos] == '#' || sqlString[pos] == '＃'))
					{
						stringBuilder.Append(sqlString[pos++]);
					}
				}
				break;
			case '"':
				sqlMicTokTyp = SqlMicTokTyp.I_VARCHAR;
				stringBuilder.Append(sqlString[pos++]);
				while (true)
				{
					if (pos >= sqlStringLen)
					{
						sqlMicTokTyp = SqlMicTokTyp.I_UNKNOWN;
						break;
					}
					if (sqlString[pos] == '"')
					{
						stringBuilder.Append(sqlString[pos++]);
						break;
					}
					stringBuilder.Append(sqlString[pos++]);
				}
				break;
			default:
				if (char.IsDigit(sqlString[pos]))
				{
					sqlMicTokTyp = SqlMicTokTyp.I_NUMLIT;
					stringBuilder.Append(sqlString[pos++]);
					while (pos < sqlStringLen && (char.IsDigit(sqlString[pos]) || sqlString[pos] == '.'))
					{
						stringBuilder.Append(sqlString[pos++]);
					}
					if (pos < sqlStringLen && (sqlString[pos] == 'e' || sqlString[pos] == 'E'))
					{
						stringBuilder.Append(sqlString[pos++]);
						if (pos < sqlStringLen && (sqlString[pos] == '+' || sqlString[pos] == '-'))
						{
							stringBuilder.Append(sqlString[pos++]);
						}
						while (pos < sqlStringLen && char.IsDigit(sqlString[pos]))
						{
							stringBuilder.Append(sqlString[pos++]);
						}
					}
				}
				else if (char.IsLetter(sqlString[pos]) || ':' == sqlString[pos])
				{
					sqlMicTokTyp = SqlMicTokTyp.I_VARCHAR;
					stringBuilder.Append(sqlString[pos++]);
					while (pos < sqlStringLen && (char.IsLetterOrDigit(sqlString[pos]) || sqlString[pos] == '_' || sqlString[pos] == '\uff3f' || sqlString[pos] == '$' || sqlString[pos] == '＄' || sqlString[pos] == '#' || sqlString[pos] == '＃'))
					{
						stringBuilder.Append(sqlString[pos++]);
					}
				}
				else
				{
					sqlMicTokTyp = SqlMicTokTyp.I_UNKNOWN;
					stringBuilder.Append(sqlString[pos++]);
				}
				break;
			}
			tokenString = stringBuilder.ToString();
			return sqlMicTokTyp;
		}

		private static SqlMacTokTyp SqlGetMacroTokenType(string token)
		{
			SqlMacTokTyp sqlMacTokTyp = SqlMacTokTyp.A_UNKNOWN;
			if (string.Compare(token, "select", ignoreCase: true) == 0)
			{
				return SqlMacTokTyp.A_SELECT;
			}
			if (string.Compare(token, "as", ignoreCase: true) == 0)
			{
				return SqlMacTokTyp.A_AS;
			}
			if (string.Compare(token, "all", ignoreCase: true) == 0)
			{
				return SqlMacTokTyp.A_ALL;
			}
			if (string.Compare(token, "distinct", ignoreCase: true) == 0)
			{
				return SqlMacTokTyp.A_DISTINCT;
			}
			if (string.Compare(token, "unique", ignoreCase: true) == 0)
			{
				return SqlMacTokTyp.A_UNIQUE;
			}
			if (string.Compare(token, "from", ignoreCase: true) == 0)
			{
				return SqlMacTokTyp.A_FROM;
			}
			if (string.Compare(token, "where", ignoreCase: true) == 0)
			{
				return SqlMacTokTyp.A_AFTERFROM;
			}
			if (string.Compare(token, "order", ignoreCase: true) == 0)
			{
				return SqlMacTokTyp.A_AFTERFROM;
			}
			if (string.Compare(token, "start", ignoreCase: true) == 0)
			{
				return SqlMacTokTyp.A_AFTERFROM;
			}
			if (string.Compare(token, "connect", ignoreCase: true) == 0)
			{
				return SqlMacTokTyp.A_AFTERFROM;
			}
			if (string.Compare(token, "group", ignoreCase: true) == 0)
			{
				return SqlMacTokTyp.A_AFTERFROM;
			}
			if (string.Compare(token, "with", ignoreCase: true) == 0)
			{
				return SqlMacTokTyp.A_AFTERFROM;
			}
			if (string.Compare(token, "union", ignoreCase: true) == 0)
			{
				return SqlMacTokTyp.A_AFTERFROM;
			}
			if (string.Compare(token, "intersect", ignoreCase: true) == 0)
			{
				return SqlMacTokTyp.A_AFTERFROM;
			}
			if (string.Compare(token, "minus", ignoreCase: true) == 0)
			{
				return SqlMacTokTyp.A_AFTERFROM;
			}
			if (string.Compare(token, "table", ignoreCase: true) == 0)
			{
				return SqlMacTokTyp.A_AFTERFROM;
			}
			if (string.Compare(token, "for", ignoreCase: true) == 0)
			{
				return SqlMacTokTyp.A_AFTERFROM;
			}
			if (string.Compare(token, "fetch", ignoreCase: true) == 0)
			{
				return SqlMacTokTyp.A_AFTERFROM;
			}
			if (string.Compare(token, "user", ignoreCase: true) == 0)
			{
				return SqlMacTokTyp.A_PSEUDOCOL;
			}
			if (string.Compare(token, "uid", ignoreCase: true) == 0)
			{
				return SqlMacTokTyp.A_PSEUDOCOL;
			}
			if (string.Compare(token, "sysdate", ignoreCase: true) == 0)
			{
				return SqlMacTokTyp.A_PSEUDOCOL;
			}
			if (string.Compare(token, "rowid", ignoreCase: true) == 0)
			{
				return SqlMacTokTyp.A_PSEUDOCOL;
			}
			if (string.Compare(token, "rownum", ignoreCase: true) == 0)
			{
				return SqlMacTokTyp.A_PSEUDOCOL;
			}
			if (string.Compare(token, "level", ignoreCase: true) == 0)
			{
				return SqlMacTokTyp.A_PSEUDOCOL;
			}
			if (string.Compare(token, "currval", ignoreCase: true) == 0)
			{
				return SqlMacTokTyp.A_PSEUDOCOL;
			}
			if (string.Compare(token, "nextval", ignoreCase: true) == 0)
			{
				return SqlMacTokTyp.A_PSEUDOCOL;
			}
			if (string.Compare(token, "case", ignoreCase: true) == 0)
			{
				return SqlMacTokTyp.A_CASE;
			}
			return SqlMacTokTyp.A_UNKNOWN;
		}

		internal static bool DoSqlLocalProcessing(ref string commandText, bool addRowid, out bool bFoundRowidInSql, OracleConnectionImpl connImpl, OracleConnection conn)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.SQLParser, OracleTraceFuncName.DoSqlLocalProcessing);
			}
			try
			{
				bFoundRowidInSql = false;
				string cmdText = commandText;
				if (connImpl != null && connImpl.m_pm != null)
				{
					bool addedRowId = false;
					if (connImpl.m_pm.TryGetSqlWithRowId(ref commandText, out bFoundRowidInSql, out addedRowId))
					{
						return addedRowId;
					}
				}
				OracleCommandImpl.TrimCommentsFromSQL(ref cmdText);
				bool? bIsDefineInSelect = null;
				if (OracleCommandImpl.GetSqlStatementType(cmdText, ref bIsDefineInSelect) != 0)
				{
					return false;
				}
				List<SqlData> sqlTokList = null;
				List<SqlData> tableList = null;
				uint numberOfTables = 0u;
				bool wildcard = false;
				bool onlyWildcard = false;
				bool distinct = false;
				string cmdText2 = commandText;
				bool parseFailed = false;
				try
				{
					if (!SqlPreLocalBuild(commandText, addRowid, out sqlTokList, out tableList, out numberOfTables, out distinct, out wildcard, out onlyWildcard, out bFoundRowidInSql, out parseFailed))
					{
						return false;
					}
					if (addRowid)
					{
						if (bFoundRowidInSql || numberOfTables > 1)
						{
							return false;
						}
						Dictionary<string, List<SqlData>> tableColumnsMap = null;
						if (!parseFailed)
						{
							if (!SqlRebuildSQL(sqlTokList, tableList, out var newSQL, numberOfTables, onlyWildcard, addRowid, connImpl, conn, ref tableColumnsMap))
							{
								return false;
							}
							commandText = newSQL;
						}
						return true;
					}
					return false;
				}
				finally
				{
					if (connImpl != null && connImpl.m_pm != null)
					{
						connImpl.m_pm.CacheSqlWithRowIdInfo(cmdText2, commandText, bFoundRowidInSql);
					}
				}
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, OracleTraceTag.Error, OracleTraceClassName.SQLParser, OracleTraceFuncName.DoSqlLocalProcessing, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.SQLParser, OracleTraceFuncName.DoSqlLocalProcessing);
				}
			}
		}

		internal static bool GetSchemaMetaData(SQLMetaData sqlMetInfo, OracleConnection conn, OracleConnectionImpl connImpl, bool metadataHasImplicitROWIDColumn)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.SQLParser, OracleTraceFuncName.GetSchemaMetaData);
			}
			try
			{
				if (sqlMetInfo == null)
				{
					return false;
				}
				if (sqlMetInfo.bStmtParsed)
				{
					return true;
				}
				if (string.IsNullOrWhiteSpace(sqlMetInfo.pCommandText))
				{
					if (sqlMetInfo.m_sqlMetaInfo == SQLLocalParsePrimaryKeyInfo.Null || sqlMetInfo.m_sqlMetaInfo == null)
					{
						if (sqlMetInfo.m_noOfColumns > 0)
						{
							sqlMetInfo.m_sqlMetaInfo = new SQLLocalParsePrimaryKeyInfo(sqlMetInfo.m_noOfColumns);
						}
						else
						{
							sqlMetInfo.m_sqlMetaInfo = SQLLocalParsePrimaryKeyInfo.Null;
						}
					}
					return false;
				}
				lock (sqlMetInfo.m_syncLP)
				{
					if (sqlMetInfo.bStmtParsed)
					{
						return true;
					}
					if (connImpl.m_cs.m_metadataPooling && connImpl.m_pm.TryRetrieveLocalParseInfoFromCache(connImpl.ServiceName, sqlMetInfo.pCommandText, ref sqlMetInfo))
					{
						return true;
					}
					if (sqlMetInfo.m_sqlMetaInfo == SQLLocalParsePrimaryKeyInfo.Null || sqlMetInfo.m_sqlMetaInfo == null)
					{
						if (sqlMetInfo.m_noOfColumns > 0)
						{
							sqlMetInfo.m_sqlMetaInfo = new SQLLocalParsePrimaryKeyInfo(sqlMetInfo.m_noOfColumns);
						}
						else
						{
							sqlMetInfo.m_sqlMetaInfo = SQLLocalParsePrimaryKeyInfo.Null;
						}
					}
					bool flag = false;
					if (ConfigBaseClass.m_bUseLegacyLocalParser || flag)
					{
						List<SqlData> sqlTokList = null;
						List<SqlData> tableList = null;
						uint numberOfTables = 0u;
						bool wildcard = false;
						bool onlyWildcard = false;
						bool distinct = false;
						bool rowIdCol = false;
						bool parseFailed = false;
						SqlPreLocalBuild(sqlMetInfo.pCommandText, addRowid: false, out sqlTokList, out tableList, out numberOfTables, out distinct, out wildcard, out onlyWildcard, out rowIdCol, out parseFailed);
						SqlLocalBuildEx(connImpl, sqlMetInfo, tableList, numberOfTables, sqlTokList, onlyWildcard, (uint)sqlMetInfo.m_noOfColumns, metadataHasImplicitROWIDColumn, parseFailed);
					}
					sqlMetInfo.bStmtParsed = (sqlMetInfo.m_sqlMetaInfo.bStmtParsed = true);
					if (connImpl.m_cs.m_metadataPooling)
					{
						connImpl.m_pm.TryCacheLocalParsePrimaryKeyInfo(connImpl.ServiceName, sqlMetInfo.pCommandText, sqlMetInfo);
					}
				}
				return true;
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, OracleTraceTag.Error, OracleTraceClassName.SQLParser, OracleTraceFuncName.GetSchemaMetaData, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.SQLParser, OracleTraceFuncName.GetSchemaMetaData);
				}
			}
		}

		private static bool SqlLocalBuildEx(OracleConnectionImpl connImpl, SQLMetaData sqlMetaData, List<SqlData> tableList, uint numberOfTables, List<SqlData> sqlTokList, bool onlyWildcard, uint noOfpMeta, bool metadataHasImplicitROWIDColumn, bool parseFailed)
		{
			if (sqlMetaData.bGotDescribeInfoFromDB)
			{
				bool bUnresolvedColumn = false;
				Dictionary<string, List<SqlData>> tableColumnsMap = null;
				string newSQL = sqlMetaData.pCommandText;
				if (!parseFailed && !SqlRebuildSQL(sqlTokList, tableList, out newSQL, numberOfTables, onlyWildcard, bAddRowid: false, connImpl, null, ref tableColumnsMap))
				{
					return false;
				}
				if (numberOfTables == 1 && !SqlPopulateTableSchemaInfo(ref sqlMetaData.m_sqlMetaInfo, tableList))
				{
					return false;
				}
				if (!SqlFillMetaAttr(newSQL, ref sqlMetaData, tableList, numberOfTables, onlyWildcard, noOfpMeta, metadataHasImplicitROWIDColumn))
				{
					return false;
				}
				if (!SqlFixColTabSch(ref sqlMetaData, numberOfTables, tableList, noOfpMeta, out bUnresolvedColumn))
				{
					return false;
				}
				if (bUnresolvedColumn)
				{
					if (tableColumnsMap == null && !SqlGetColumnsForAllTables(connImpl, null, tableList, out tableColumnsMap, addQuotes: false))
					{
						return false;
					}
					if (!SqlGetResolveAllCols(ref sqlMetaData.m_sqlMetaInfo, tableList, tableColumnsMap, numberOfTables, noOfpMeta))
					{
						return false;
					}
					if (!SqlFixColTabSch(ref sqlMetaData, numberOfTables, tableList, noOfpMeta, out bUnresolvedColumn))
					{
						return false;
					}
				}
			}
			return true;
		}

		private static bool SqlPopulateTableSchemaInfo(ref SQLLocalParsePrimaryKeyInfo sqlParseInfo, List<SqlData> tableList)
		{
			SqlGetTableName(tableList, 1u, SqlMacTokTyp.A_TABLE, out var tabName, out var _);
			if (tabName != null)
			{
				SplitTableString(tabName, out sqlParseInfo.m_schemaName, out sqlParseInfo.m_tableName, out var _);
				if (sqlParseInfo.m_tableName != null)
				{
					if (sqlParseInfo.m_tableName.Length != 0 && sqlParseInfo.m_tableName[0] != '"')
					{
						sqlParseInfo.m_tableName = sqlParseInfo.m_tableName.ToUpperInvariant();
					}
					sqlParseInfo.m_tableName = sqlParseInfo.m_tableName.Trim('"');
				}
				if (sqlParseInfo.m_schemaName != null)
				{
					if (sqlParseInfo.m_schemaName.Length != 0 && sqlParseInfo.m_schemaName[0] != '"')
					{
						sqlParseInfo.m_schemaName = sqlParseInfo.m_schemaName.ToUpperInvariant();
					}
					sqlParseInfo.m_schemaName = sqlParseInfo.m_schemaName.Trim('"');
				}
			}
			return true;
		}

		private static void SqlGetTableName(List<SqlData> tabList, uint TableNum, SqlMacTokTyp AliasOrActual, out string tabName, out uint idAliasOrActual)
		{
			tabName = null;
			idAliasOrActual = 8u;
			for (int i = 0; i < tabList.Count; i++)
			{
				SqlData sqlData = tabList[i];
				SqlData sqlData2 = null;
				if (i + 1 < tabList.Count)
				{
					sqlData2 = tabList[i + 1];
				}
				if (sqlData.m_tag == 8 && sqlData.m_id == TableNum)
				{
					if (AliasOrActual == SqlMacTokTyp.A_TABALIAS && sqlData2 != null && sqlData2.m_tag == 9 && sqlData2.m_id == TableNum)
					{
						tabName = sqlData2.m_data;
						idAliasOrActual = sqlData2.m_tag;
					}
					else
					{
						tabName = sqlData.m_data;
						idAliasOrActual = sqlData.m_tag;
					}
					break;
				}
			}
		}

		public static void SplitTableString(string inStr, out string schema_Name, out string table_Name, out string dbLink)
		{
			schema_Name = null;
			table_Name = null;
			dbLink = null;
			int num = 0;
			char c = '"';
			if (inStr.Contains(c))
			{
				bool flag = false;
				bool flag2 = false;
				List<string> list = new List<string>();
				for (int i = 0; i < inStr.Length; i++)
				{
					char c2 = inStr[i];
					if (c2.Equals(c))
					{
						flag = !flag;
					}
					else if (!flag)
					{
						if (c2.Equals('.') && !flag2)
						{
							string item = inStr.Substring(num, i - num);
							list.Add(item);
							num = i + 1;
						}
						if (c2.Equals('@') && !flag2)
						{
							flag2 = true;
							string item2 = inStr.Substring(num, i - num);
							list.Add(item2);
							dbLink = inStr.Substring(i + 1, inStr.Length - (i + 1));
							num = inStr.Length;
						}
					}
				}
				if (num < inStr.Length)
				{
					string item3 = inStr.Substring(num, inStr.Length - num);
					list.Add(item3);
				}
				if (list.Count == 1)
				{
					table_Name = list[0];
				}
				else if (list.Count == 2)
				{
					schema_Name = list[0];
					table_Name = list[1];
				}
				return;
			}
			char value = '@';
			if (inStr.Contains(value))
			{
				string[] array = inStr.Split(new char[1]
				{
					'@'
				}, 2);
				dbLink = array[1];
				string[] array2 = array[0].Split('.');
				if (array2.Length == 1)
				{
					table_Name = array2[0];
				}
				else if (array2.Length == 2)
				{
					table_Name = array2[1];
					schema_Name = array2[0];
				}
			}
			else
			{
				string[] array3 = inStr.Split('.');
				if (array3.Length == 1)
				{
					table_Name = array3[0];
				}
				else if (array3.Length == 2)
				{
					table_Name = array3[1];
					schema_Name = array3[0];
				}
			}
		}

		private static bool SqlFillMetaAttr(string commandText, ref SQLMetaData sqlMetadata, List<SqlData> tabList, uint NoOfTables, bool bOnlyWildcard, uint NoOfpMeta, bool metadataHasImplicitROWIDColumn)
		{
			List<SqlData> sqlDataList = null;
			List<SqlData> tableList = null;
			string tabName = null;
			bool wildCard = false;
			if (bOnlyWildcard && NoOfTables == 1)
			{
				for (uint num = 0u; num < NoOfpMeta; num++)
				{
					ColumnDescribeInfo columnDescribeInfo = sqlMetadata.m_columnDescribeInfo[num];
					ColumnLocalParsePrimaryKeyInfo columnLocalParsePrimaryKeyInfo = sqlMetadata.m_sqlMetaInfo.m_columnMetaInfo[num];
					columnLocalParsePrimaryKeyInfo.m_columnName = columnDescribeInfo.pColAlias;
					columnLocalParsePrimaryKeyInfo.Updatable = true;
					columnLocalParsePrimaryKeyInfo.bIsExpression = false;
					if (num == NoOfpMeta - 1 && metadataHasImplicitROWIDColumn && (columnDescribeInfo.m_dataType == 11 || columnDescribeInfo.m_dataType == 208))
					{
						columnLocalParsePrimaryKeyInfo.m_columnName = "ROWID";
						columnLocalParsePrimaryKeyInfo.Updatable = false;
						columnLocalParsePrimaryKeyInfo.bIsExpression = true;
					}
					SqlGetTableName(tabList, 1u, SqlMacTokTyp.A_TABALIAS, out tabName, out var idAliasOrActual);
					if (tabName != null && tabName.Length != 0 && idAliasOrActual == 9)
					{
						columnLocalParsePrimaryKeyInfo.pTabAlias = tabName;
						if (columnLocalParsePrimaryKeyInfo.pTabAlias != null && columnLocalParsePrimaryKeyInfo.pTabAlias.Length != 0 && columnLocalParsePrimaryKeyInfo.pTabAlias[0] != '"')
						{
							columnLocalParsePrimaryKeyInfo.pTabAlias = columnLocalParsePrimaryKeyInfo.pTabAlias.ToUpperInvariant();
						}
						columnLocalParsePrimaryKeyInfo.pTabAlias = columnLocalParsePrimaryKeyInfo.pTabAlias.Trim('"');
					}
					SqlGetTableName(tabList, 1u, SqlMacTokTyp.A_TABLE, out tabName, out idAliasOrActual);
					SplitTableString(tabName, out columnLocalParsePrimaryKeyInfo.m_schemaName, out columnLocalParsePrimaryKeyInfo.pTabName, out var _);
					if (columnLocalParsePrimaryKeyInfo.pTabName != null)
					{
						if (columnLocalParsePrimaryKeyInfo.pTabName.Length != 0 && columnLocalParsePrimaryKeyInfo.pTabName[0] != '"')
						{
							columnLocalParsePrimaryKeyInfo.pTabName = columnLocalParsePrimaryKeyInfo.pTabName.ToUpperInvariant();
						}
						columnLocalParsePrimaryKeyInfo.pTabName = columnLocalParsePrimaryKeyInfo.pTabName.Trim('"');
					}
					if (columnLocalParsePrimaryKeyInfo.m_schemaName != null)
					{
						if (columnLocalParsePrimaryKeyInfo.m_schemaName.Length != 0 && columnLocalParsePrimaryKeyInfo.m_schemaName[0] != '"')
						{
							columnLocalParsePrimaryKeyInfo.m_schemaName = columnLocalParsePrimaryKeyInfo.m_schemaName.ToUpperInvariant();
						}
						columnLocalParsePrimaryKeyInfo.m_schemaName = columnLocalParsePrimaryKeyInfo.m_schemaName.Trim('"');
					}
				}
			}
			else
			{
				SqlParse(commandText, out sqlDataList);
				bool distinct = false;
				bool bFoundRowidInSql = false;
				SqlReadSQLTokenList(sqlDataList, ref tableList, out NoOfTables, out wildCard, out bOnlyWildcard, out distinct, out bFoundRowidInSql);
				int num2 = 0;
				int num3 = sqlMetadata.m_columnDescribeInfo.Length;
				ColumnDescribeInfo columnDescribeInfo2 = null;
				ColumnLocalParsePrimaryKeyInfo columnLocalParsePrimaryKeyInfo2 = null;
				foreach (SqlData item in sqlDataList)
				{
					uint num4 = item.m_id & 0xFFFFFFFu;
					uint num5 = item.m_id & 0xF0000000u;
					if (num4 != 6)
					{
						continue;
					}
					if (num2 < num3)
					{
						columnDescribeInfo2 = sqlMetadata.m_columnDescribeInfo[num2];
						columnLocalParsePrimaryKeyInfo2 = sqlMetadata.m_sqlMetaInfo.m_columnMetaInfo[num2];
						if (num5 == 0 || columnDescribeInfo2.m_dataType == 11 || columnDescribeInfo2.m_dataType == 208)
						{
							columnLocalParsePrimaryKeyInfo2.Updatable = true;
							columnLocalParsePrimaryKeyInfo2.bIsExpression = false;
							splitColumnString(item.m_data, out columnLocalParsePrimaryKeyInfo2.m_schemaName, out columnLocalParsePrimaryKeyInfo2.pTabName, out columnLocalParsePrimaryKeyInfo2.m_columnName);
							if (columnLocalParsePrimaryKeyInfo2.m_columnName != null)
							{
								if (columnLocalParsePrimaryKeyInfo2.m_columnName.Length != 0 && columnLocalParsePrimaryKeyInfo2.m_columnName[0] != '"')
								{
									columnLocalParsePrimaryKeyInfo2.m_columnName = columnLocalParsePrimaryKeyInfo2.m_columnName.ToUpperInvariant();
								}
								columnLocalParsePrimaryKeyInfo2.m_columnName = columnLocalParsePrimaryKeyInfo2.m_columnName.Trim('"');
								if (columnLocalParsePrimaryKeyInfo2.m_columnName == "ROWID")
								{
									columnLocalParsePrimaryKeyInfo2.Updatable = false;
									columnLocalParsePrimaryKeyInfo2.bIsExpression = true;
								}
							}
							if (columnLocalParsePrimaryKeyInfo2.pTabName != null)
							{
								if (columnLocalParsePrimaryKeyInfo2.pTabName.Length != 0 && columnLocalParsePrimaryKeyInfo2.pTabName[0] != '"')
								{
									columnLocalParsePrimaryKeyInfo2.pTabName = columnLocalParsePrimaryKeyInfo2.pTabName.ToUpperInvariant();
								}
								columnLocalParsePrimaryKeyInfo2.pTabName = columnLocalParsePrimaryKeyInfo2.pTabName.Trim('"');
							}
							if (columnLocalParsePrimaryKeyInfo2.m_schemaName != null)
							{
								if (columnLocalParsePrimaryKeyInfo2.m_schemaName.Length != 0 && columnLocalParsePrimaryKeyInfo2.m_schemaName[0] != '"')
								{
									columnLocalParsePrimaryKeyInfo2.m_schemaName = columnLocalParsePrimaryKeyInfo2.m_schemaName.ToUpperInvariant();
								}
								columnLocalParsePrimaryKeyInfo2.m_schemaName = columnLocalParsePrimaryKeyInfo2.m_schemaName.Trim('"');
							}
						}
						else
						{
							columnLocalParsePrimaryKeyInfo2.Updatable = false;
							columnLocalParsePrimaryKeyInfo2.bIsExpression = true;
						}
						num2++;
						continue;
					}
					if (ProviderConfig.m_bTraceLevelPrivate)
					{
						Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Error, OracleTraceClassName.SQLParser, OracleTraceFuncName.SqlFillMetaAttr, "SqlParser::SqlFillMetaAttr() - column count mismatch");
					}
					return false;
				}
			}
			return true;
		}

		private static void splitColumnString(string inStr, out string schemaName, out string tableName, out string columnName)
		{
			columnName = (tableName = (schemaName = null));
			int num = 0;
			char c = '"';
			if (inStr.Contains(c))
			{
				bool flag = false;
				List<string> list = new List<string>();
				for (int i = 0; i < inStr.Length; i++)
				{
					char c2 = inStr[i];
					if (c2.Equals(c))
					{
						flag = !flag;
					}
					else if (!flag && c2.Equals('.'))
					{
						string item = inStr.Substring(num, i - num);
						list.Add(item);
						num = i + 1;
					}
				}
				if (num < inStr.Length)
				{
					string item2 = inStr.Substring(num, inStr.Length - num);
					list.Add(item2);
				}
				if (list.Count == 1)
				{
					columnName = list[0];
				}
				else if (list.Count == 2)
				{
					tableName = list[0];
					columnName = list[1];
				}
				else if (list.Count == 3)
				{
					schemaName = list[0];
					tableName = list[1];
					columnName = list[2];
				}
			}
			else
			{
				string[] array = inStr.Split('.');
				if (array.Length == 1)
				{
					columnName = array[0];
				}
				else if (array.Length == 2)
				{
					columnName = array[1];
					tableName = array[0];
				}
				else if (array.Length == 3)
				{
					columnName = array[2];
					tableName = array[1];
					schemaName = array[0];
				}
			}
		}

		private static bool SqlRebuildSQL(List<SqlData> sqlTokList, List<SqlData> tabList, out string newSQL, uint NoOfTables, bool bOnlyWildcard, bool bAddRowid, OracleConnectionImpl connImpl, OracleConnection conn, ref Dictionary<string, List<SqlData>> tableColumnsMap)
		{
			newSQL = string.Empty;
			StringBuilder newSQLBuilder = new StringBuilder();
			foreach (SqlData sqlTok in sqlTokList)
			{
				uint num = sqlTok.m_id & 0xFFFFFFFu;
				if ((sqlTok.m_id & 0xF0000000u) == 268435456)
				{
					string tabName;
					uint idAliasOrActual;
					string table_Name;
					if (bOnlyWildcard && NoOfTables == 1)
					{
						tabName = sqlTok.m_data;
						if (tabName.Split('.', '@').Length > 1)
						{
							newSQLBuilder.Append(sqlTok.m_data);
							continue;
						}
						SqlGetTableName(tabList, 1u, SqlMacTokTyp.A_TABALIAS, out tabName, out idAliasOrActual);
						SplitTableString(tabName, out var _, out table_Name, out var _);
						tabName = table_Name;
						newSQLBuilder.Append(tabName);
						newSQLBuilder.Append(".");
						newSQLBuilder.Append(sqlTok.m_data);
						continue;
					}
					splitColumnString(sqlTok.m_data, out var schemaName, out table_Name, out var _);
					if (tableColumnsMap == null && !SqlGetColumnsForAllTables(connImpl, conn, tabList, out tableColumnsMap, addQuotes: true))
					{
						return false;
					}
					if (table_Name != null && table_Name.Length > 0)
					{
						SqlAddColNames(ref newSQLBuilder, tableColumnsMap, tabList, table_Name, schemaName);
						continue;
					}
					uint num2 = 1u;
					while (true)
					{
						SqlGetTableName(tabList, num2, SqlMacTokTyp.A_TABALIAS, out tabName, out idAliasOrActual);
						if (tabName == null || tabName.Length <= 0)
						{
							break;
						}
						SplitTableString(tabName, out schemaName, out table_Name, out var _);
						if (num2 > 1)
						{
							newSQLBuilder.Append(", ");
						}
						if (table_Name != null && table_Name.Length > 0)
						{
							SqlAddColNames(ref newSQLBuilder, tableColumnsMap, tabList, table_Name, schemaName);
						}
						num2++;
					}
				}
				else if (num == 5)
				{
					if (bAddRowid && !SqlAppendRowid(ref newSQLBuilder, tabList))
					{
						return false;
					}
					newSQLBuilder.Append(" ");
					newSQLBuilder.Append(sqlTok.m_data);
					newSQLBuilder.Append(" ");
				}
				else
				{
					newSQLBuilder.Append(sqlTok.m_data);
					newSQLBuilder.Append(" ");
				}
			}
			newSQL = newSQLBuilder.ToString();
			return true;
		}

		private static void SqlAddColNames(ref StringBuilder newSQLBuilder, Dictionary<string, List<SqlData>> tableColumnsMap, List<SqlData> tabList, string tabName, string schemaName)
		{
			uint index = 0u;
			uint idAliasOrActual = 0u;
			string table_Name = null;
			if (tabName != null && tabName.Length > 0)
			{
				if (!SqlGetTableIndex(tabList, tabName, out index, out idAliasOrActual))
				{
					return;
				}
				SplitTableString(tabName, out var _, out table_Name, out var _);
			}
			SqlGetTableName(tabList, index, SqlMacTokTyp.A_TABLE, out var tabName2, out idAliasOrActual);
			List<SqlData> list = tableColumnsMap[tabName2];
			int count = list.Count;
			for (int i = 0; i < count; i++)
			{
				if (schemaName != null && schemaName.Length > 0)
				{
					newSQLBuilder.Append(schemaName);
					newSQLBuilder.Append(".");
				}
				if (tabName != null && tabName.Length > 0)
				{
					newSQLBuilder.Append(table_Name);
					newSQLBuilder.Append(".");
				}
				SqlData sqlData = list[i];
				newSQLBuilder.Append(sqlData.m_data);
				if (i < count - 1)
				{
					newSQLBuilder.Append(", ");
				}
				else
				{
					newSQLBuilder.Append(" ");
				}
			}
		}

		private static bool SqlGetTableIndex(List<SqlData> tabList, string tabName, out uint index, out uint idAliasOrActual, bool tokenizeTableName = true)
		{
			index = 0u;
			idAliasOrActual = 0u;
			foreach (SqlData tab in tabList)
			{
				string strA;
				if (tokenizeTableName)
				{
					SplitTableString(tab.m_data, out var _, out var table_Name, out var _);
					if (table_Name == null)
					{
						return false;
					}
					string[] array = table_Name.Split('@');
					_ = array.Length;
					strA = ((array.Length <= 1) ? array[0] : array[1]);
				}
				else
				{
					if (tab.m_data == null)
					{
						return false;
					}
					strA = tab.m_data;
				}
				if (string.Compare(strA, tabName, ignoreCase: true) == 0)
				{
					index = tab.m_id;
					idAliasOrActual = tab.m_tag;
					return true;
				}
			}
			return false;
		}

		private static bool SqlFixColTabSch(ref SQLMetaData sqlMetadata, uint NoOfTables, List<SqlData> tabList, uint NoOfpMeta, out bool bUnresolvedColumn)
		{
			SQLLocalParsePrimaryKeyInfo sqlMetaInfo = sqlMetadata.m_sqlMetaInfo;
			bUnresolvedColumn = false;
			for (uint num = 0u; num < NoOfpMeta; num++)
			{
				ColumnLocalParsePrimaryKeyInfo columnLocalParsePrimaryKeyInfo = sqlMetaInfo.m_columnMetaInfo[num];
				if (columnLocalParsePrimaryKeyInfo.pTabName != null && columnLocalParsePrimaryKeyInfo.pTabName.Length > 0 && SqlGetTableIndex(tabList, columnLocalParsePrimaryKeyInfo.pTabName, out var index, out var idAliasOrActual) && idAliasOrActual == 9)
				{
					uint idAliasOrActual2;
					if (columnLocalParsePrimaryKeyInfo.pTabAlias == null || columnLocalParsePrimaryKeyInfo.pTabAlias.Length == 0)
					{
						SqlGetTableName(tabList, index, SqlMacTokTyp.A_TABALIAS, out var tabName, out idAliasOrActual2);
						if (tabName != null && tabName.Length > 0 && idAliasOrActual2 == 9)
						{
							columnLocalParsePrimaryKeyInfo.pTabAlias = tabName;
						}
					}
					SqlGetTableName(tabList, index, SqlMacTokTyp.A_TABLE, out var tabName2, out idAliasOrActual2);
					if (tabName2 != null && tabName2.Length > 0)
					{
						SplitTableString(tabName2, out columnLocalParsePrimaryKeyInfo.m_schemaName, out columnLocalParsePrimaryKeyInfo.pTabName, out var _);
						if (columnLocalParsePrimaryKeyInfo.pTabName != null && columnLocalParsePrimaryKeyInfo.pTabName.Length != 0)
						{
							if (columnLocalParsePrimaryKeyInfo.pTabName[0] != '"')
							{
								columnLocalParsePrimaryKeyInfo.pTabName = columnLocalParsePrimaryKeyInfo.pTabName.ToUpperInvariant();
							}
							columnLocalParsePrimaryKeyInfo.pTabName = columnLocalParsePrimaryKeyInfo.pTabName.Trim('"');
						}
						if (columnLocalParsePrimaryKeyInfo.m_schemaName != null && columnLocalParsePrimaryKeyInfo.m_schemaName.Length != 0)
						{
							if (columnLocalParsePrimaryKeyInfo.m_schemaName[0] != '"')
							{
								columnLocalParsePrimaryKeyInfo.m_schemaName = columnLocalParsePrimaryKeyInfo.m_schemaName.ToUpperInvariant();
							}
							columnLocalParsePrimaryKeyInfo.m_schemaName = columnLocalParsePrimaryKeyInfo.m_schemaName.Trim('"');
						}
					}
				}
				if ((columnLocalParsePrimaryKeyInfo.pTabName == null || columnLocalParsePrimaryKeyInfo.pTabName.Length == 0) && (columnLocalParsePrimaryKeyInfo.Updatable || columnLocalParsePrimaryKeyInfo.m_columnName == "ROWID"))
				{
					if (sqlMetaInfo.m_tableName != null && sqlMetaInfo.m_tableName.Length > 0 && NoOfTables == 1)
					{
						columnLocalParsePrimaryKeyInfo.pTabName = sqlMetaInfo.m_tableName;
					}
					else
					{
						bUnresolvedColumn = true;
					}
				}
				if ((columnLocalParsePrimaryKeyInfo.m_schemaName == null || columnLocalParsePrimaryKeyInfo.m_schemaName.Length == 0) && (columnLocalParsePrimaryKeyInfo.Updatable || columnLocalParsePrimaryKeyInfo.m_columnName == "ROWID") && sqlMetaInfo.m_schemaName != null && sqlMetaInfo.m_schemaName.Length > 0 && NoOfTables == 1)
				{
					columnLocalParsePrimaryKeyInfo.m_schemaName = sqlMetaInfo.m_schemaName;
				}
			}
			return true;
		}

		private static bool SqlGetResolveAllCols(ref SQLLocalParsePrimaryKeyInfo sqlParseInfo, List<SqlData> tabList, Dictionary<string, List<SqlData>> tableColumnMap, uint NoOfTables, uint NoOfpMeta)
		{
			for (uint num = 0u; num < NoOfpMeta; num++)
			{
				ColumnLocalParsePrimaryKeyInfo columnLocalParsePrimaryKeyInfo = sqlParseInfo.m_columnMetaInfo[num];
				bool flag = columnLocalParsePrimaryKeyInfo.pTabName != null && columnLocalParsePrimaryKeyInfo.pTabName.Length > 0;
				bool flag2 = columnLocalParsePrimaryKeyInfo.m_schemaName != null && columnLocalParsePrimaryKeyInfo.m_schemaName.Length > 0;
				if ((flag && flag2) || !columnLocalParsePrimaryKeyInfo.Updatable)
				{
					continue;
				}
				string colName = ((columnLocalParsePrimaryKeyInfo.m_columnName[0] != '"') ? columnLocalParsePrimaryKeyInfo.m_columnName : columnLocalParsePrimaryKeyInfo.m_columnName.Trim('"'));
				if (!flag)
				{
					columnLocalParsePrimaryKeyInfo.Updatable = false;
					columnLocalParsePrimaryKeyInfo.bIsExpression = true;
				}
				foreach (string key in tableColumnMap.Keys)
				{
					if (!SqlIsColumnInList(tableColumnMap[key], colName))
					{
						continue;
					}
					if (!SqlGetTableIndex(tabList, key, out var index, out var _, tokenizeTableName: false))
					{
						return false;
					}
					uint idAliasOrActual2;
					if (columnLocalParsePrimaryKeyInfo.pTabAlias == null || columnLocalParsePrimaryKeyInfo.pTabAlias.Length <= 0)
					{
						SqlGetTableName(tabList, index, SqlMacTokTyp.A_TABALIAS, out var tabName, out idAliasOrActual2);
						if (tabName != null && tabName.Length > 0 && idAliasOrActual2 == 9)
						{
							columnLocalParsePrimaryKeyInfo.pTabAlias = tabName;
						}
					}
					SqlGetTableName(tabList, index, SqlMacTokTyp.A_TABLE, out var tabName2, out idAliasOrActual2);
					if (tabName2 == null || tabName2.Length <= 0)
					{
						break;
					}
					SplitTableString(tabName2, out var schema_Name, out var table_Name, out var _);
					columnLocalParsePrimaryKeyInfo.Updatable = true;
					columnLocalParsePrimaryKeyInfo.bIsExpression = false;
					if (!flag && table_Name != null)
					{
						columnLocalParsePrimaryKeyInfo.pTabName = table_Name;
						if (columnLocalParsePrimaryKeyInfo.pTabName.Length != 0 && columnLocalParsePrimaryKeyInfo.pTabName[0] != '"')
						{
							columnLocalParsePrimaryKeyInfo.pTabName = columnLocalParsePrimaryKeyInfo.pTabName.ToUpperInvariant();
						}
						columnLocalParsePrimaryKeyInfo.pTabName = columnLocalParsePrimaryKeyInfo.pTabName.Trim('"');
					}
					if (!flag2 && schema_Name != null)
					{
						columnLocalParsePrimaryKeyInfo.m_schemaName = schema_Name;
						if (columnLocalParsePrimaryKeyInfo.m_schemaName.Length != 0 && columnLocalParsePrimaryKeyInfo.m_schemaName[0] != '"')
						{
							columnLocalParsePrimaryKeyInfo.m_schemaName = columnLocalParsePrimaryKeyInfo.m_schemaName.ToUpperInvariant();
						}
						columnLocalParsePrimaryKeyInfo.m_schemaName = columnLocalParsePrimaryKeyInfo.m_schemaName.Trim('"');
					}
					break;
				}
			}
			return true;
		}

		private static bool SqlIsColumnInList(List<SqlData> columnList, string colName)
		{
			foreach (SqlData column in columnList)
			{
				if (column.m_data == colName)
				{
					return true;
				}
			}
			return false;
		}

		private static bool SqlGetColumnsForAllTables(OracleConnectionImpl connImpl, OracleConnection conn, List<SqlData> tableList, out Dictionary<string, List<SqlData>> tableColumnMap, bool addQuotes)
		{
			tableColumnMap = new Dictionary<string, List<SqlData>>();
			foreach (SqlData table in tableList)
			{
				if (table.m_tag == 8)
				{
					List<SqlData> columnList = null;
					if (!SqlGetColumns(connImpl, conn, table.m_data, out columnList, addQuotes))
					{
						return false;
					}
					tableColumnMap[table.m_data] = columnList;
				}
			}
			return true;
		}

		private static bool SqlGetColumns(OracleConnectionImpl connImpl, OracleConnection conn, string tableName, out List<SqlData> columnList, bool addQuotes)
		{
			columnList = new List<SqlData>();
			SQLMetaData sqlMetadata = null;
			int hiddenColumnCount = 0;
			new OracleCommandImpl().RetrieveMetadata("SELECT * FROM " + tableName, CommandType.Text, null, connImpl, conn, out sqlMetadata, out hiddenColumnCount);
			if (sqlMetadata == null || !sqlMetadata.bGotDescribeInfoFromDB)
			{
				return false;
			}
			ColumnDescribeInfo[] columnDescribeInfo = sqlMetadata.m_columnDescribeInfo;
			foreach (ColumnDescribeInfo columnDescribeInfo2 in columnDescribeInfo)
			{
				if (addQuotes)
				{
					columnList.Add(new SqlData("\"" + columnDescribeInfo2.pColAlias + "\"", 6u, 0u));
				}
				else
				{
					columnList.Add(new SqlData(columnDescribeInfo2.pColAlias, 6u, 0u));
				}
			}
			return true;
		}

		private static bool SqlAppendRowid(ref StringBuilder newSQLBuilder, List<SqlData> tabList)
		{
			uint num = 1u;
			while (true)
			{
				SqlGetTableName(tabList, num, SqlMacTokTyp.A_TABALIAS, out var tabName, out var _);
				if (tabName == null || tabName.Length <= 0)
				{
					break;
				}
				SplitTableString(tabName, out var _, out var table_Name, out var _);
				tabName = table_Name;
				newSQLBuilder.Append(string.Format(", {0}.{1} ", tabName, "ROWID"));
				num++;
			}
			return true;
		}
	}
}
